import java.util.Scanner;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: LENOVO
 * Date: 2024-08-04
 * Time: 16:32
 */
class Login {
    private  String userName;
    private String password;

    public void logInfo(String userName,String password){
        if((!(this.userName.equals(userName)) ) && (!(this.password.equals(password) ))){
            System.out.println("用户名和密码输入均不一致！");
            return;
        }
        if(!(this.userName.equals(userName))){
            /*System.out.println("用户名输入不一致！");*/
            throw new RuntimeException("用户名输入不一致！");
        }
        if(!(this.password.equals(password))){
            System.out.println("密码输入不一致！");
            return;
        }
        System.out.println("注册成功！");
    }
    public Login(String userName,String password){
        this.password = password;
        this.userName = userName;
    }
}
public class Test {
    public static void main(String[] args) {

        Scanner scanner = new Scanner(System.in);
        System.out.println("请注册用户");
        System.out.println("请注册用户名：");
        String userName = scanner.nextLine();
        System.out.println("请注册用户密码：");
        String password = scanner.nextLine();
        Login login = new Login(userName,password);
        System.out.println("为确保注册成功，请再次输入用户名和密码");
        System.out.println("请输入用户名：");
        String userNameAgain = scanner.nextLine();
        System.out.println("请输入用户密码：");
        String passwordAgain = scanner.nextLine();
        login.logInfo(userNameAgain,passwordAgain);


    }
}
